{% extends "UiManager/base.html" %}
{% block title %}系统设置{% endblock %}
{% block location %}
    <div class="am-icon-home fa fa-home" style="font-weight: bold;color: grey; float: right;">&nbsp;当前位置： 全局设置 > 系统设置</div>
{% endblock %}
{% load staticfiles %}
{% block css %}
{% endblock %}
{% block js %}
    <script>
        // 提交设置
        function save() {
            var main = $("#main").val();
            var server = $("#server").val();
            var resource = $('#resource').val();
            var log = $('#log').val();
            var rabbitmq = $('#rabbitmq').val();
            var image = $('#image').val();
            var email_user = $('#email_user').val();
            var email_password = $('#email_password').val();
            var data = {
                "main_dir": main,
                "server": server,
                "log_dir": log,
                "image_dir": image,
                "rabbitMq_url": rabbitmq,
                "email_user": email_user,
                "email_password": email_password,
                "resource_dir": resource,
            };
            $.ajax({
                url: '/ui/edit_system_settings/',
                type: 'post',
                data: JSON.stringify(data),
                dataType: 'json',
                success: function (res) {
                    if (res.code == 0) {
                        alert('提交成功');
                        location.reload();
                    } else {
                        $(".js_message").html(res.message);
                    }
                }
            });
        }
    </script>
{% endblock %}
{% block content %}
<div id="page-wrapper">
        <div id="page-inner">
            <!--内容-->
            <div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <!--<div class="panel-heading">表格名字</div>-->
                        <div class="panel-body width-p8" style="min-height:500px">
                            <form class="form-horizontal" role="form">
                                <div class="form-group">
                                    <label for="main" class="col-sm-2 control-label">appium main.js启动文件路径</label>
                                    <div class="col-sm-10">
                                        <input id='main' type="text" class="form-control" value="{{ obj.main_dir }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="server" class="col-sm-2 control-label">服务器地址</label>
                                    <div class="col-sm-10">
                                        <input id='server' type="text" class="form-control" placeholder="为空默认：localhost" value="{{ obj.server }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="resource" class="col-sm-2 control-label">资源存放路径</label>
                                    <div class="col-sm-10">
                                        <input id='resource' type="text" class="form-control" value="{{ obj.resource_dir }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="log" class="col-sm-2 control-label">日志存放路径</label>
                                    <div class="col-sm-10">
                                        <input id='log' type="text" class="form-control" value="{{ obj.log_dir }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="image" class="col-sm-2 control-label">截图存放路径</label>
                                    <div class="col-sm-10">
                                        <input id='image' type="text" class="form-control" value="{{ obj.image_dir }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="rabbitmq" class="col-sm-2 control-label">rabbitmq连接地址</label>
                                    <div class="col-sm-10">
                                        <input id='rabbitmq' type="text" class="form-control" placeholder="为空默认：amqp://guest:guest@127.0.0.1:5672//" value="{{ obj.rabbitMq_url }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="email_user" class="col-sm-2 control-label">发送报告邮箱地址</label>
                                    <div class="col-sm-10">
                                        <input id='email_user' type="text" class="form-control" value="{{ obj.email_user }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="email_password" class="col-sm-2 control-label">发送报告邮箱密码</label>
                                    <div class="col-sm-10">
                                        <input id='email_password' type="password" class="form-control" value="{{ obj.email_password }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="message" class="col-sm-2 control-label"></label>
                                    <div class="col-sm-10 js_message text-danger"></div>
                                </div>
                                <div class="form-group">
                                    <label for="lastname" class="col-sm-2 control-label"></label>
                                    <div class="col-sm-10">
                                        <button type="button" class="btn btn-primary mar-rignt-20"
                                                onclick="save()">提交
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <!--内容-->

            <!--内容end-->
        </div>
        <!-- /. PAGE INNER  -->
    </div>
{% endblock %}